<template>
  <x-popup height="440" v-model="show" title="减免费用操作">
    <x-input label="原收款金额" :disabled="true" v-model="money" suffix="元" placeholder="原收款金额" :required="true">

    </x-input>
    <x-input label="现收款金额" v-model="amount" suffix="元" placeholder="现收款金额" :required="true"></x-input>

    <x-bottom>
      <view class="note">注：提交后，用户将按减免后的金额支付。</view>
      <view @click="onSubmit" class="x-btn x-btn-primary">提交</view>
    </x-bottom>
  </x-popup>
</template>

<script setup>
import XPopup from '@/components/lib/popup';
import billStore from '@/stores/modules/bill';
const BillStore = billStore();
import {ref} from 'vue';
const show = ref(false)

const id = ref("");
const money = ref("");
const amount = ref("");
const open = (billId, leftMoney) => {
  show.value = true;
  id.value = billId
  money.value = leftMoney
}
const emit = defineEmits(['success']);
const onSubmit = async () => {
  let isOk = await BillStore.eduction(id.value, amount.value);
  if(isOk) {
    show.value = false;
    emit("success", id.value)
  }
}

defineExpose({open})
</script>

<style scoped lang="less">
.note {
  color: red;
  font-size: 24rpx;
  padding-bottom: 10rpx;
  box-sizing: border-box;
  text-align: center;
}
</style>
